line = addExclamation("Hello") |
return a |
def addExclamation(a): |
a = a + "!" |
print(line) |
line = addExclamation("Hello") |
  return a |
def addExclamation(a): |
  a = a + "!" |
print(line) |
1 | def addExclamation(a): |
2 |   a = a + "!" |
3 |   return a |
4 | |
5 | line = addExclamation("Hello") |
6 | print(line) |
def tenTimes(a): |
return a |
x = tenTimes(3) |
a = a * 10 |
print(x) |
def tenTimes(a): |
  return a |
x = tenTimes(3) |
  a = a * 10 |
print(x) |
1 | def tenTimes(a): |
2 |   a = a * 10 |
3 |   return a |
4 | |
5 | x = tenTimes(3) |
6 | print(x) |
x = addFive(3) |
a = a + 5 |
return a |
print(x+y) |
def addFive(a): |
y = addFive(10) |
x = addFive(3) |
  a = a + 5 |
  return a |
print(x+y) |
def addFive(a): |
y = addFive(10) |
1 | def addFive(a): |
2 |   a = a + 5 |
3 |   return a |
4 | |
5 | x = addFive(3) |
6 | y = addFive(10) |
7 | print(x+y) |
x = isA("A") |
print(x) |
return True |
y = isA("B") |
if a == "A": |
def isA(a): |
return False |
print(y) |
else: |
x = isA("A") |
print(x) |
    return True |
y = isA("B") |
  if a == "A": |
def isA(a): |
    return False |
print(y) |
  else: |
1 | def isA(a): |
2 |   if a == "A": |
3 |     return True |
4 |   else: |
5 |     return False |
6 | |
7 | x = isA("A") |
8 | print(x) |
9 | y = isA("B") |
10 | print(y) |
def add(a,b): |
c = a + b |
print(w) |
return c |
w = add(5,10) |
def add(a,b): |
  c = a + b |
print(w) |
  return c |
w = add(5,10) |
1 | def add(a,b): |
2 |   c = a + b |
3 |   return c |
4 | |
5 | |
6 | w = add(5,10) |
7 | print(w) |
c = a * b |
print(w) |
w = area(20,10) |
def area(a,b): |
return c |
  c = a * b |
print(w) |
w = area(20,10) |
def area(a,b): |
  return c |
1 | def area(a,b): |
2 |   c = a * b |
3 |   return c |
4 | |
5 | w = area(20,10) |
6 | print(w) |
w = perimeter(20,10) |
print(w) |
def perimeter(a,b): |
return c |
c = a * 2 + b * 2 |
w = perimeter(20,10) |
print(w) |
def perimeter(a,b): |
  return c |
  c = a * 2 + b * 2 |
1 | def perimeter(a,b): |
2 |   c = a * 2 + b * 2 |
3 |   return c |
4 | |
5 | w = perimeter(20,10) |
6 | print(w) |
a = a * 2 |
r = multiTwo(8) |
def multiTwo(a): |
print(r) |
return a |
  a = a * 2 |
r = multiTwo(8) |
def multiTwo(a): |
print(r) |
  return a |
1 | def multiTwo(a): |
2 |   a = a * 2 |
3 |   return a |
4 | |
5 | r = multiTwo(8) |
6 | print(r) |
def multiTwo(a): |
a = a * 2 |
return a |
y = multiTwo(10) |
print(x + y) |
x = multiTwo(20) |
def multiTwo(a): |
  a = a * 2 |
  return a |
y = multiTwo(10) |
print(x + y) |
x = multiTwo(20) |
1 | def multiTwo(a): |
2 |   a = a * 2 |
3 |   return a |
4 | |
5 | x = multiTwo(20) |
6 | y = multiTwo(10) |
7 | print(x + y) |
def combineStr(a,b): |
c = a + " " + b |
x = combineStr("hello","friend") |
print(x) |
return c |
def combineStr(a,b): |
  c = a + " " + b |
x = combineStr("hello","friend") |
print(x) |
  return c |
1 | def combineStr(a,b): |
2 |   c = a + " " + b |
3 |   return c |
4 | |
5 | x = combineStr("hello","friend") |
6 | print(x) |
def isSame(a,b): |
l1 = a[0] |
print(r) |
else: |
r = isSame("hello","hi") |
l2 = a[1] |
if l1 == l2: |
return True |
return False |
def isSame(a,b): |
  l1 = a[0] |
print(r) |
  else: |
r = isSame("hello","hi") |
  l2 = a[1] |
  if l1 == l2: |
    return True |
    return False |
1 | def isSame(a,b): |
2 |   l1 = a[0] |
3 |   l2 = a[1] |
4 |   if l1 == l2: |
5 |     return True |
6 |   else: |
7 |     return False |
8 | |
9 | r = isSame("hello","hi") |
10 | print(r) |
if l1 == l2: |
return True |
def isSame(a,b): |
print("They start with the same character") |
i2 = input() |
i = input() |
else: |
l1 = a[0] |
if z == True: |
z = isSame(i,i2) |
l2 = a[1] |
return False |
print("Enter two inputs") |
print("They don't start with the same character") |
else: |
  if l1 == l2: |
    return True |
def isSame(a,b): |
  print("They start with the same character") |
i2 = input() |
i = input() |
else: |
  l1 = a[0] |
if z == True: |
z = isSame(i,i2) |
  l2 = a[1] |
    return False |
print("Enter two inputs") |
  print("They don't start with the same character") |
  else: |
1 | def isSame(a,b): |
2 |   l1 = a[0] |
3 |   l2 = a[1] |
4 |   if l1 == l2: |
5 |     return True |
6 |   else: |
7 |     return False |
8 | |
9 | print("Enter two inputs") |
10 | i = input() |
11 | i2 = input() |
12 | z = isSame(i,i2) |
13 | if z == True: |
14 |   print("They start with the same character") |
15 | else: |
16 |   print("They don't start with the same character") |
empty = empty.strip() |
for x in range(len(arr)): |
return empty |
print(result) |
empty = "" |
def printArray(arr): |
empty = empty + arr[x] + " " |
result = printArray(["this","is","a","test"]) |
  empty = empty.strip() |
  for x in range(len(arr)): |
  return empty |
print(result) |
  empty = "" |
def printArray(arr): |
    empty = empty + arr[x] + " " |
result = printArray(["this","is","a","test"]) |
1 | def printArray(arr): |
2 |   empty = "" |
3 |   for x in range(len(arr)): |
4 |     empty = empty + arr[x] + " " |
5 |   empty = empty.strip() |
6 |   return empty |
7 | |
8 | result = printArray(["this","is","a","test"]) |
9 | print(result) |
#Remember when a return happens the function ends, if it gets to the other if statements must be false |
first = int(first) |
if second > 12 or second < 1: |
second = a[3:5] |
second = int(second) |
result = isdate("12/15/2021") |
first = a[0:2] |
return True |
print(result) |
if first > 31 or first < 1: |
return False |
def isdate(a): |
return False |
  #Remember when a return happens the function ends, if it gets to the other if statements must be false |
  first = int(first) |
  if second > 12 or second < 1: |
  second = a[3:5] |
  second = int(second) |
result = isdate("12/15/2021") |
  first = a[0:2] |
  return True |
print(result) |
  if first > 31 or first < 1: |
    return False |
def isdate(a): |
    return False |
1 | def isdate(a): |
2 |   first = a[0:2] |
3 |   first = int(first) |
4 |   if first > 31 or first < 1: |
5 |     return False |
6 |    |
7 |   second = a[3:5] |
8 |   second = int(second) |
9 |   if second > 12 or second < 1: |
10 |     return False |
11 |   #Remember when a return happens the function ends, if it gets to the other if statements must be false |
12 |   return True |
13 |    |
14 | |
15 | result = isdate("12/15/2021") |
16 | print(result) |
valid = isdate(i) |
break |
def isdate(a): |
if second > 12 or second < 1: |
second = a[3:5] |
return False |
i = input() |
first = a[0:2] |
else: |
while True: |
print("Enter a date in the format dd/mm/yyyy") |
first = int(first) |
return True |
return False |
if valid == True: |
if first > 31 or first < 1: |
print("Not valid, please try again") |
second = int(second) |
  valid = isdate(i) |
    break |
def isdate(a): |
  if second > 12 or second < 1: |
  second = a[3:5] |
    return False |
  i = input() |
  first = a[0:2] |
  else: |
while True: |
  print("Enter a date in the format dd/mm/yyyy") |
  first = int(first) |
  return True |
    return False |
  if valid == True: |
  if first > 31 or first < 1: |
    print("Not valid, please try again") |
  second = int(second) |
1 | def isdate(a): |
2 |   first = a[0:2] |
3 |   first = int(first) |
4 |   if first > 31 or first < 1: |
5 |     return False |
6 |    |
7 |   second = a[3:5] |
8 |   second = int(second) |
9 |   if second > 12 or second < 1: |
10 |     return False |
11 |   return True |
12 |    |
13 | |
14 | while True: |
15 |   print("Enter a date in the format dd/mm/yyyy") |
16 |   i = input() |
17 |   valid = isdate(i) |
18 |   if valid == True: |
19 |     break |
20 |   else: |
21 |     print("Not valid, please try again") |
arr.append(a + x) |
arr = [] |
length = b - a |
def numArray(a,b): |
return arr |
print(numArray(5,8)) |
for x in range(length): |
    arr.append(a + x) |
  arr = [] |
  length = b - a |
def numArray(a,b): |
  return arr |
print(numArray(5,8)) |
  for x in range(length): |
1 | def numArray(a,b): |
2 |   length = b - a |
3 |   arr = [] |
4 |   for x in range(length): |
5 |     arr.append(a + x) |
6 |   return arr |
7 | print(numArray(5,8)) |
print(x) |
for x in numArray(1,21): |
  print(x) |
for x in numArray(1,21): |
1 | for x in numArray(1,21): |
2 |   print(x) |
3 |    |
maxNum = maxArr([5,4,2,1]) |
return m |
m = arr[0] |
for x in range(1,len(arr)): |
if arr[x] > m: |
m = arr[x] |
print(maxNum) |
def maxArr(arr): |
maxNum = maxArr([5,4,2,1]) |
  return m |
  m = arr[0] |
  for x in range(1,len(arr)): |
    if arr[x] > m: |
      m = arr[x] |
print(maxNum) |
def maxArr(arr): |
1 | def maxArr(arr): |
2 |   m = arr[0] |
3 |   for x in range(1,len(arr)): |
4 |     if arr[x] > m: |
5 |       m = arr[x] |
6 |   return m |
7 | |
8 | maxNum = maxArr([5,4,2,1]) |
9 | print(maxNum) |
i = getIndex([5,4,2,1],1) |
for x in range(len(arr)): |
return -1 #invalid |
def getIndex(arr,a): |
print(i) |
return x |
if arr[x] == a: |
i = getIndex([5,4,2,1],1) |
  for x in range(len(arr)): |
  return -1 #invalid |
def getIndex(arr,a): |
print(i) |
      return x |
    if arr[x] == a: |
1 | def getIndex(arr,a): |
2 |   for x in range(len(arr)): |
3 |     if arr[x] == a: |
4 |       return x |
5 |   return -1 #invalid |
6 | |
7 | i = getIndex([5,4,2,1],1) |
8 | print(i) |
idx = getIndex(arr,num) |
def maxIndex(arr): |
print(maxIndex([5,2,1,8,2])) |
return idx |
num = maxArr(arr) |
  idx = getIndex(arr,num) |
def maxIndex(arr): |
print(maxIndex([5,2,1,8,2])) |
  return idx |
  num = maxArr(arr) |
1 | def maxIndex(arr): |
2 |   num = maxArr(arr) |
3 |   idx = getIndex(arr,num) |
4 |   return idx |
5 | print(maxIndex([5,2,1,8,2])) |
empty = "" |
for x in range(len(s)): |
sb = spaceBad("this is a test string") |
print(sb) |
if s[x] != " ": |
empty = empty + s[x] |
def spaceBad(s): |
return empty |
  empty = "" |
  for x in range(len(s)): |
sb = spaceBad("this is a test string") |
print(sb) |
    if s[x] != " ": |
      empty = empty + s[x] |
def spaceBad(s): |
  return empty |
1 | def spaceBad(s): |
2 |   empty = "" |
3 |   for x in range(len(s)): |
4 |     if s[x] != " ": |
5 |       empty = empty + s[x] |
6 |   return empty |
7 | |
8 | sb = spaceBad("this is a test string") |
9 | print(sb) |
s = s + " " |
for x in range(a - len(s)): |
space = addSpaces("cs",10) |
print(space + "|") |
space = addSpaces("test",10) |
return s |
def addSpaces(s,a): |
print(space + "|") |
    s = s + " " |
  for x in range(a - len(s)): |
space = addSpaces("cs",10) |
print(space + "|") |
space = addSpaces("test",10) |
  return s |
def addSpaces(s,a): |
print(space + "|") |
1 | def addSpaces(s,a): |
2 |   for x in range(a - len(s)): |
3 |     s = s + " " |
4 |   return s |
5 | |
6 | space = addSpaces("test",10) |
7 | print(space + "|") |
8 | space = addSpaces("cs",10) |
9 | print(space + "|") |
empty = s[0].upper() |
empty = empty + s[x].upper() |
return empty |
if empty[x - 1] == " ": |
for x in range(1,len(s)): |
print(title) |
else: |
title = capitalise("this is a test") |
empty = empty + s[x] |
def capitalise(s): |
  empty = s[0].upper() |
      empty = empty + s[x].upper() |
  return empty |
    if empty[x - 1] == " ": |
  for x in range(1,len(s)): |
print(title) |
    else: |
title = capitalise("this is a test") |
      empty = empty + s[x] |
def capitalise(s): |
1 | def capitalise(s): |
2 |   empty = s[0].upper() |
3 |   for x in range(1,len(s)): |
4 |     if empty[x - 1] == " ": |
5 |       empty = empty + s[x].upper() |
6 |     else: |
7 |       empty = empty + s[x] |
8 |   return empty |
9 | |
10 | title = capitalise("this is a test") |
11 | print(title) |
def logicNot(a): |
def logicAnd(a,b): |
return False |
else: |
return True |
else: |
return True |
return False |
if a == True and b == True: |
print(logicNot(False)) |
def logicOr(a,b): |
return True |
else: |
if a == True or b == True: |
print(logicAnd(True,True)) |
print(logicOr(True,False)) |
return False |
if a == True: |
def logicNot(a): |
def logicAnd(a,b): |
    return False |
  else: |
    return True |
  else: |
    return True |
    return False |
  if a == True and b == True: |
print(logicNot(False)) |
def logicOr(a,b): |
    return True |
  else: |
  if a == True or b == True: |
print(logicAnd(True,True)) |
print(logicOr(True,False)) |
    return False |
  if a == True: |
1 | def logicAnd(a,b): |
2 |   if a == True and b == True: |
3 |     return True |
4 |   else: |
5 |     return False |
6 | |
7 | def logicOr(a,b): |
8 |   if a == True or b == True: |
9 |     return True |
10 |   else: |
11 |     return False |
12 | |
13 | def logicNot(a): |
14 |   if a == True: |
15 |     return False |
16 |   else: |
17 |     return True |
18 |    |
19 | print(logicAnd(True,True)) |
20 | print(logicOr(True,False)) |
21 | print(logicNot(False)) |
B = False |
A = True |
result = logicOr(logicAnd(A,B),logicNot(C)) |
C = False |
print(result) |
1 | A = True |
2 | B = False |
3 | C = False |
4 | result = logicOr(logicAnd(A,B),logicNot(C)) |
5 | print(result) |
B = False |
print(result) |
result = logicOr(logicNot(logicAnd(A,B)),logicOr(logicNot(C),D)) |
A = True |
C = False |
D = True |
1 | A = True |
2 | B = False |
3 | C = False |
4 | D = True |
5 | result = logicOr(logicNot(logicAnd(A,B)),logicOr(logicNot(C),D)) |
6 | print(result) |